import { reqEchartsData, type EchartsData } from '@/api/echarts' //引入reqEchartsData
import { ElMessage} from "element-plus" //引入ElMessage
import { defineStore } from "pinia" //引入defineStore

// 约定仓库中state返回数据的类型
interface EchartsStoreState {
    echartsData: EchartsData,
}
export const useEchartsStore = defineStore("echarts", {
    state: (): EchartsStoreState => {
        return {
            echartsData: {
                //1": "今日销售额",
                salesToday: 0,
                salesLastDay: 0,
                salesGrowthLastDay: 0,
                salesGrowthLastMonth: 0,
                // 2今日订单量
                orderToday: 0,
                orderLastDay: 0,
                orderTrend: [],
                //3": "今日交易用户数"
                orderUserToday: 0,
                returnRate: 0,
                orderUserTrend: [],
                orderUserTrendAxis: [],

                //4: "累计用户数",
                usersTotal: 0,
                usersLastDay: 0,
                usersLastMonth: 0,
                userGrowthLastDay: "",//"17.70",有小数点的类型是string  ,string不带数组的替换为""
                userGrowthLastMonth: 0,//有小数点的类型是string
                // /5": "销售额与访问量
                orderFullYearAxis: [],
                orderFullYear: [],
                userFullYearAxis: [],
                userFullYear: [],
                orderRank: [] ,
                userRank: [],
                searchWord: [],

                //8": "分类销售排行"
                saleRank: {
                    category: {
                        axisX: [],
                        data1: [],
                    },
                    goods: {
                        axisX: [],
                        data1: [],
                    },
                },
            }
        }
    },
    actions:{
        //请求数据
        async getEchartsData() {
            try {
                const res = await reqEchartsData() //
            } catch (error) {
            ElMessage.error("获取图表数据失败")  
            }
    }
},
getters: {},
})